package com.longge;

import java.util.LinkedList;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-05-09 23:13
 */
public class CreateTargetArray {

    public int[] createTargetArray(int[] nums, int[] index) {
        LinkedList<Integer> target = new LinkedList<>();
        for (int i = 0; i < index.length; i++) {
            target.add(index[i],nums[i]);
        }
        int[] res = new int[nums.length];
        for (int i = 0; i < res.length; i++) {
            res[i]=target.get(i);
        }
        return res;
    }

    public static void main(String[] args) {
        new CreateTargetArray().createTargetArray(new int[]{0,1,2,3,4},new int[]{0,1,2,2,1});
    }

}
